package georah.map.providers
{

	import georah.carto.Extent;
	import georah.carto.IGISClient;
	import georah.carto.PanZoom;
	import georah.map.tools.IPointQueryProvider;

	/**
	 *
	 * @author yuanm
	 */
	public final class WMSFeatureInfo implements IPointQueryProvider
	{
		private var _baseurl:String="";

		private var _featureInfoURL:String=null;

		private var _format:String="application/vnd.ogc.gml";

		public final function get baseURL():String
		{
			return _baseurl;
		}

		public final function set baseURL(value:String):void
		{
			_baseurl=value;
		}

		public final function featureInfoURL(x:Number, y:Number):String
		{
			return _featureInfoURL + "x=" + x + "&y=" + y;
		}

		public final function get format():String
		{
			return _format;
		}

		public final function set format(value:String):void
		{
			_format=value;
		}

		public final function update(view:IGISClient):void
		{
			var bbox:Extent=PanZoom(view.camera).calcBBox(view.width, view.height);

			_featureInfoURL=baseURL + "request=getfeatureinfo&info_format=" + format + "&srs=EPSG:" + view.camera.where.SRID + "&bbox=" + bbox.minX + "," + bbox.minY + "," + bbox.maxX + "," + bbox.maxY + "&width=" + view.width + "&height=" + view.height + "&";
		}

	}
}
